home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
ddj0997.zip
/
cprog997.txt
< prev
next >
Wrap
Text File
|
1997-07-22
|
2KB
|
111 lines
_C Programming Column_
by Al Stevens
Listing One
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char msg[25];
strcpy(msg, "The random number is: ");
cout << msg << rand() << endl;
return 0;
}
Listing Two
#ifndef _IOSTREAM
#define _IOSTREAM
namespace std {
#include <iostream.h>
}
#endif
Listing Three
#ifndef _CSTDLIB
#define _CSTDLIB
namespace std {
#include <stdlib.h>
}
#endif
Listing Four
#include <iostream>
#include <cstring>
#include <cstdlib>
int main()
{
char msg[25];
std::strcpy(msg, "The random number is: ");
std::cout << msg << std::rand() << std::endl;
return 0;
}
Listing Five
// ------- main.cpp
#include <fstream>
using namespace std;
void foo(ofstream& ofile);
int main()
{
ofstream ofile("test.txt");
foo(ofile);
return 0;
}
// ------- foo.cpp
#include <fstream.h>
void foo(ofstream& ofile)
{
ofile << "Hello Dolly";
}
Listing Six
#include <fstream>
using namespace std;
void foo(ofstream& ofile)
{
ofile << "Hello Dolly";
}
Listing Seven
#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;
int main()
{
char msg[25];
strcpy(msg, "The random number is: ");
cout << msg << rand() << endl;
return 0;
}
Listing Eight
#ifndef _IOSTREAM
#define _IOSTREAM
#include <iostream.h>
#ifndef using
#define using /* */
#define namespace /* */
#define std /* */
#endif
#endif